package com.lj.queue.result;

import com.lj.queue.entity.DelayQueueMessage;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;

/**
 * <p>
 * 延迟队列消息表 分页结果
 * </p>
 *
 * @author lj
 * @since 2025-07-21 16:55:02
 */
@Data
@Schema(description = "延迟队列消息表 分页结果")
public class DelayQueueMessagePageResult {

    @Schema(description = "主键id ")
    private Long id;

    @Schema(description = "延迟队列id ")
    private Long queueId;

    @Schema(description = "消息内容 ")
    private String message;

    @Schema(description = "消息状态 参考字典: DelayQueueMessageStatus")
    private Integer status;

    @Schema(description = "预计时间 ")
    private LocalDateTime expectTime;

    public static DelayQueueMessagePageResult of(DelayQueueMessage entity) {
        if (entity == null) {
            return null;
        }
        DelayQueueMessagePageResult result = new DelayQueueMessagePageResult();
        result.setId(entity.getId());
        result.setQueueId(entity.getQueueId());
        result.setMessage(entity.getMessage());
        result.setStatus(entity.getStatus() != null ? entity.getStatus().getValue() : null);
        result.setExpectTime(entity.getExpectTime());
        return result;
    }
}
